package app.server.project.core.http;


import app.server.project.core.constants.Def;
import app.server.project.core.exception.GlobalException;
import app.server.project.core.exception.SysError;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

@Slf4j
@ControllerAdvice
public class GlobalRespAdvice  {

    @ExceptionHandler(GlobalException.class)
    @ResponseBody
    public RespModel doGlobalException(GlobalException e) {
        return RespModel.error(e.getCode());
    }


    @ExceptionHandler(Exception.class)
    public void doException(GlobalException e) {
        log.error("捕获到系统级别错误",e);
    }

}
